# Maintainer: Justin Kromlinger <hashworks@archlinux.org>

pkgname='opensearch-cli'
pkgver=1.1.0
pkgrel=4
pkgdesc="A full-featured command line interface (CLI) for OpenSearch"
url='https://opensearch.org/docs/latest/clients/cli/'
arch=('loong64' 'x86_64')
license=('Apache')
depends=('glibc')
makedepends=('go')
source=(
  "${pkgname}-${pkgver}.tar.gz::https://github.com/opensearch-project/opensearch-cli/archive/refs/tags/${pkgver}.tar.gz")
sha512sums=('e21bfebfd5f7d342360c66412f89628106246600ea7c198ca1eec896a1285b6b690da6bd893f6f4b39e9ebf3157e351c563f450899719d2804336c866fe48534')

prepare() {
  cd ${pkgname}-${pkgver}
  go mod vendor
}

build() {
  cd ${pkgname}-${pkgver}
  export CGO_CPPFLAGS="${CPPFLAGS}"
  export CGO_CFLAGS="${CFLAGS}"
  export CGO_CXXFLAGS="${CXXFLAGS}"
  export CGO_LDFLAGS="${LDFLAGS}"
  export GOFLAGS="-buildmode=pie -trimpath -mod=readonly -modcacherw -ldflags=-linkmode=external"
  go build -v -o ${pkgname} .
}

package() {
  cd ${pkgname}-${pkgver}
  install -Dm644 "LICENSE" "${pkgdir}/usr/share/licenses/${pkgname}/LICENSE"
  install -Dm755 ${pkgname} -t "${pkgdir}"/usr/bin/
}

# vim: ts=2 sw=2 et:
